package cn.dev.mybatis.util;

import java.lang.reflect.Type;
import java.util.Date;

/**
 * 类操作工具
 *
 * @since 2025-02-12
 */
public class ClassUtils {

    private static final Class<?>[] PRIMARY_CLASS_ARRAY =
            {byte.class, short.class, int.class, long.class, float.class, double.class, boolean.class, char.class,
                    Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Boolean.class, Character.class,
                    String.class, Date.class};

    private ClassUtils() {
    }

    public static boolean isPrimaryClass(Type type) {
        for (Class<?> primaryClass : PRIMARY_CLASS_ARRAY) {
            if (primaryClass == type) {
                return true;
            }
        }
        return false;
    }

    public static boolean isNotPrimaryObject(Object obj) {
        for (Class<?> primaryClass : PRIMARY_CLASS_ARRAY) {
            if (primaryClass.isInstance(obj)) {
                return false;
            }
        }
        return true;
    }

    public static boolean isAllPrimaryObject(Object[] objs) {
        for (Object obj : objs) {
            if (isNotPrimaryObject(obj)) {
                return false;
            }
        }
        return true;
    }
}
